package com.gupaoedu.task.pattern.observer.guavatask;

import com.google.common.eventbus.EventBus;

/**
 * @author djl
 * @Title: GuavaEventTest
 * @Description: TODO
 * @date 2019/3/31
 */
public class GuavaEventTest {
    public static void main(String[] args) {
        //消息总线
/*        EventBus eventBus = new EventBus();
        GuavaEvent guavaEvent = new GuavaEvent();
        eventBus.register(guavaEvent);
        eventBus.post("Tom");*/

        //从Struts到SpringMVC的升级
        //因为Struts面向的类，而SpringMVC面向的是方法

        //前面两者面向的是类，Guava面向是方法

        //能够轻松落地观察模式的一种解决方案
        //MQ

        //Guava  Guper社区提问通知
        Question question = new Question();
        question.setUserName("小明");
        question.setContent("观察者设计模式适用于哪些场景？");
        Teacher tom = new Teacher("Tom");
        Teacher mic = new Teacher("Mic");
        //消息总线
        EventBus eventBus = new EventBus();

        GuavaEvent guavaEvent = GuavaEvent.getInstance();
        eventBus.register(guavaEvent);
        eventBus.register(tom);
        eventBus.register(mic);
        eventBus.post(question);
    }
}
